package reflection.proxy;

import java.io.InputStream;
import java.util.Properties;

/**
 * @author DuJiabao
 * @create 2021-01-12 22:33
 * 动态代理
 */
public class ProxyTest {
    public static void main(String[] args) throws Exception {
//        根据properties获取动态的类
        Properties properties = new Properties();
        ClassLoader classLoader = ProxyTest.class.getClassLoader();
        InputStream resourceAsStream = classLoader.getResourceAsStream("reflection/proxy/config.properties");
        properties.load(resourceAsStream);
        Class<?> aClass = Class.forName(properties.getProperty("Class"));
        Human o = (Human) aClass.newInstance();
//      动态代理
        Human proxyInstance = (Human) ProxyFactory.getProxyInstance(o);
        proxyInstance.drink();
        proxyInstance.eat();
    }
}
